unit DelphiCodeUI;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, SynEditHighlighter, SynHighlighterPas, SynEdit,
  SynHighlighterSQL, SynHighlighterJava, SynEditMiscClasses, Menus;

type
  TDelphiCodeForm = class(TForm)
    SynPasSyn1: TSynPasSyn;
    SynJavaSyn1: TSynJavaSyn;
    SynSQLSyn1: TSynSQLSyn;
    SynEdit1: TSynEdit;
    PopupMenu1: TPopupMenu;
    N1: TMenuItem;
    N2: TMenuItem;
    OpenDialog: TOpenDialog;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure N1Click(Sender: TObject);
  private
    { Private declarations }
  private ffilename: string;
  private fprojectDir: string;
  protected
    procedure SetFileName(value: string);
    procedure SetProjectDir(value: string);

  public

    { Public declarations }
    procedure save;
    procedure DirectSave;
    property filename: string read Ffilename write setfilename;
    property ProjectDir: string read fProjectDir write SetProjectDir;

  end;

var
  DelphiCodeForm: TDelphiCodeForm;

implementation

{$R *.dfm}

procedure TDelphiCodeForm.SetFileName(value: string);
begin
  Ffilename := value;
  caption := value;
end;

procedure TDelphiCodeForm.SetProjectDir(value: string);
begin
  fProjectDir := value;
end;

procedure TDelphiCodeForm.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  Action := caFree;
end;

procedure TDelphiCodeForm.N1Click(Sender: TObject);
begin
//    if OpenDialog.Execute then
//    SynEdit1
end;

procedure TDelphiCodeForm.save;
begin
  opendialog.FileName := self.filename;
  if OpenDialog.Execute then
  begin
    self.filename := extractfilename(OpenDialog.FileName);
    self.ProjectDir := ExtractFileDir(Opendialog.FileName);
    DirectSave;
  end;
end;

procedure TDelphiCodeForm.DirectSave;
begin
  SynEdit1.Lines.SaveToFile(projectdir +'\'+filename);
end;
end.

